﻿using System;

namespace KuiHuaBaoDian.Services.Lockstep {

    /// <summary>
    /// 帧同步句柄
    /// </summary>
    public readonly struct LockstepEntityHandle {

        /// <summary>
        /// 空值
        /// </summary>
        public static readonly LockstepEntityHandle None = new();

        /// <summary>
        /// GUID
        /// </summary>
        public Guid GUID { get; init; }

        public override readonly string ToString() => $"[{nameof(LockstepEntityHandle)}({GUID})]";

        public override readonly int GetHashCode() => GUID.GetHashCode();

        public override bool Equals(object obj) {
            if (obj is LockstepEntityHandle other) {
                return other.GUID == GUID;
            }
            return false;
        }

        public static bool operator ==(LockstepEntityHandle left, LockstepEntityHandle right) => left.Equals(right);
        public static bool operator !=(LockstepEntityHandle left, LockstepEntityHandle right) => !left.Equals(right);
    }
}
